﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Simple.Common.Core.Hosting;

namespace Simple.Common.Application.Commands
{
    public class CommandHandler
    {
        private IMediator _bus;
        protected IMediator Bus
        {
            get { return _bus ??= ServiceProviderHelper.GetService<IMediator>(); }
        }

        private IHttpContextAccessor _httpContextAccessor;
        /// <summary>
        /// Http context accessor
        /// </summary>
        public IHttpContextAccessor HttpContextAccessor
        {
            get => _httpContextAccessor;
            set => _httpContextAccessor ??= ServiceProviderHelper.GetService<IHttpContextAccessor>();
        }
    }
}